package com.xiaobai.controller;

import com.xiaobai.common.Article;
import com.xiaobai.common.CommonMoon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/moon")
public class MoonController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("/dog")
    public List<String> dog(){
        List<String> list = stringRedisTemplate.opsForSet().randomMembers(CommonMoon.MOON_DOG, 10);
        //一次十条
        return list;
    }

    @GetMapping("/love")
    public List<String> love(){
        List<String> list = stringRedisTemplate.opsForSet().randomMembers(CommonMoon.MOON_LOVE, 10);
        //一次十条
        return list;
    }

    @GetMapping("/soup")
    public List<String> soup(){
        List<String> list = stringRedisTemplate.opsForSet().randomMembers(CommonMoon.MOON_SOUP, 10);
        //一次十条
        return list;
    }

    @GetMapping("/article")
    public Article article(){
        Article article=CommonMoon.article;
        return article;
    }

}
